package org.example.springboot01.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springboot01.pojo.Category;

import java.util.List;


@Mapper
public interface Categorymapper {
//    新增分类列表
    @Insert("insert into category(categoryname,categoryalias,updatetime,creatime,creatuser) values(#{categoryname},#{categoryalias}," +
            "#{updatetime},#{createtime},#{createuser})")
    void addcategory(Category categoryname);
   //查询用户添加的分类
    @Select("select * from category where creatuser=#{username}")
    List<Category> getcategory(String username);
    //查询根据id查询分类
    @Select("select * from category where id=#{id}")
    List<Category> getcategorybyid(Integer id);
    @Update("update category set categoryname = #{category.categoryname},categoryalias=#{category.categoryalias},updatetime=#{category.updatetime} where id=#{id}")
    void updatecategory(@Param("category") Category category, @Param("id") Integer id);
     @Delete("delete from category where categoryname=#{name}")
    void deletecategory(String name);
}
